package com.hsd.commons.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hsd.commons.dao.ICacheDao;
import com.hsd.commons.service.ICacheService;
import com.hsd.core.base.dao.IBaseDAO;
import com.hsd.core.base.service.impl.BaseService;
import com.hsd.core.page.Finder;
import com.hsd.core.page.entity.PageParams;
import com.hsd.core.page.entity.Pagination;

@Service
public class CacheServiceImpl extends BaseService implements ICacheService{
	@Autowired
	private ICacheDao cacheDao;
	
	/**
	 * 加载字典集列表
	 * @param pageParams
	 * @return
	 */
	@Override
	public Pagination loadDicttList(PageParams pageParams,String codetype){
		Finder finder = Finder.create("from HsdAppCodeIndex");
		if(StringUtils.isNotBlank(codetype)){
			finder.append(" where codetype like:codetype"); 
			finder.setParam("codetype", "%" + codetype + "%");
		}
		finder.append(" order by startdate desc");
		Pagination page = cacheDao.find(finder, pageParams.getPageNo(), pageParams.getPageSize());
		return page;
	}
	
	@Override
	public IBaseDAO getBaseDao() {
		return this.cacheDao;
	}
	
}
